app.controller('ChancelModalCtrl', ['$scope', '$modal', '$log', '$http', '$window', '$localStorage', '$state', '$location',
        function ($scope, $modal, $log, $http, $window, $localStorage, $state, $location) {
            $scope.items = ['item1', 'item2', 'item3'];
            //console.log($state.params);
            var oid,version;
            var ModalInstanceCtrl = function ($scope, $modalInstance, items) {
                $scope.oo = {};
                $scope.items = items;
                $scope.selected = {
                    item: $scope.items[0]
                };
                $scope.ok = function () {              

                                      
                    $modalInstance.close($scope.selected.item);
                };

                $scope.cancel = function () {
                    $modalInstance.dismiss('cancel');
                };
            };
            $scope.chexiao = function(ll,nn){
              oid = ll;
              version = nn;
              $scope.open();
            }
            $scope.open = function (size) {
                var modalInstance = $modal.open({
                    templateUrl: 'chancelModalContent.html',
                    controller: ModalInstanceCtrl,
                    size: size,
                    resolve: {
                        items: function () {
                            return $scope.items;
                        }
                    }
                });
                modalInstance.result.then(function (selectedItem) {

                    $http.post(
                        $scope.app.backendurl+"tbl-violation/revoke",
                        {
                            'violation_id': oid,
                            'version': version,                               
                            'token':$localStorage.token             

                        }
                    ).success(function (data) {
                      //console.log(data);
                      if(data.code==0&&data.msg=="撤销成功"){
                        alert(data.msg);
                        $window.location.reload('app/order/breakrules');                      

                      }
                     if(data.code==1){
                        alert(data.msg);

                      }
                      if(data.code==20001){
                         $location.path('access.signin');
                       }
                    }).error(function (data) {
                        alert(data);
                    })
                });
            };
        }])
app.controller('DelModalCtrl', ['$scope', '$modal', '$log', '$http', '$window', '$localStorage', '$state', '$location',
        function ($scope, $modal, $log, $http, $window, $localStorage, $state, $location) {
            $scope.items = ['item1', 'item2', 'item3'];
            //console.log($state.params);
            var oid;
            var ModalInstanceCtrl = function ($scope, $modalInstance, items) {
                $scope.oo = {};
                $scope.items = items;
                $scope.selected = {
                    item: $scope.items[0]
                };
                $scope.ok = function () {              

                                      
                    $modalInstance.close($scope.selected.item);
                };

                $scope.cancel = function () {
                    $modalInstance.dismiss('cancel');
                };
            };
            $scope.del = function(ll){
              oid = ll;
              
              $scope.open();
            }
            $scope.open = function (size) {
                var modalInstance = $modal.open({
                    templateUrl: 'delModalContent.html',
                    controller: ModalInstanceCtrl,
                    size: size,
                    resolve: {
                        items: function () {
                            return $scope.items;
                        }
                    }
                });
                modalInstance.result.then(function (selectedItem) {

                    $http.post(
                        $scope.app.backendurl+"tbl-violation/delete",
                        {
                            'violation_id': oid,                                                      
                            'token':$localStorage.token             

                        }
                    ).success(function (data) {
                      //console.log(data);
                      if(data.code==0&&data.msg=="删除成功"){
                        alert(data.msg);
                        $window.location.reload('app/order/breakrules');                      

                      }
                     if(data.code==1){
                        alert(data.msg);

                      }
                      if(data.code==20001){
                         $location.path('access.signin');
                       }
                    }).error(function (data) {
                        alert(data);
                    })
                });
            };
        }])

